package com.bootdo.system.controller;

import com.bootdo.system.domain.FrontuserDO;
import com.bootdo.system.service.FrontuserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletRequest;

@Controller
public class BaseController {

    @Autowired
    private FrontuserService frontuserService;

    public Long getUserId(HttpServletRequest request){
        FrontuserDO user = (FrontuserDO) request.getSession().getAttribute("user");

        return user.getUserid();
    }

    public FrontuserDO getSessionUser(HttpServletRequest request){
        FrontuserDO user = (FrontuserDO) request.getSession().getAttribute("user");

        return user;
    }

    public FrontuserDO getUserDO(HttpServletRequest request){

        FrontuserDO frontuserDO = frontuserService.get(getUserId(request));

        return frontuserDO;
    }
}
